<template>
  <div class="build-el-time-list">
    <swiper :options="swiperOption" ref="mySwiper" v-if="timeList.length!=0">
      <swiper-slide v-for="(item,index) in timeList" :key="index">
        <span
          :class="active==index?'year year-active':'year'"
          @click="handYear(index,item.id)"
        >{{item.year}}年</span>
      </swiper-slide>
    </swiper>
    <!-- <div class="item">
      <div
      
      ></div>
    </div>-->
  </div>
</template>
<script>
export default {
  props: {},
  data() {
    return {
      swiperOption: {
        slidesPerView: 4,
        watchSlidesProgress: true,
        paginationType: 'progress',
      },
      active: 0,
      timeList: [],
    }
  },
  async mounted() {
    let res = await this.api.findHistoryVoteList({
      customizeId: 1,
    })
    this.swiperOption = {
      slidesPerView: 4,
      watchSlidesProgress: true,
      paginationType: 'progress',
    }
    console.log(res)
    this.timeList = res
  },
  methods: {
    handYear(index, id) {
      console.log(index)
      this.$emit('handYear', id)
      this.active = index
    },
  },
}
</script>
<style scoped lang="less">
.build-el-time-list {
  .year {
    color: #9a9a9a;
    font-size: 16px;
    height: 37px;
    line-height: 37px;
    position: relative;
    margin-bottom: 32px;
    width: 86px;
    white-space: nowrap;
  }
  .year-active {
    color: #303030;
    font-size: 18px;
    height: 37px;
    line-height: 37px;
    position: relative;
    width: 86px;
    text-align: left;
    font-weight: bold;
    white-space: nowrap;
    &::after {
      content: '';
      position: absolute;
      bottom: -6px;
      left: 50%;
      margin-left: -9.5px;
      width: 19px;
      height: 3px;
      background-color: #666666;
    }
  }
}
</style>
